# dockerfile.ubuntu.jdk.txt.sh
# By Elvin , 2020

FROM ubuntu:xenial

ENV JAVA_HOME=/opt/local/java/latest \
    JRE_HOME=$JAVA_HOME/jre \
    CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib \
    PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

RUN echo  && \
    #use aliyun source,and install#
    sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/' /etc/apt/sources.list && \
    sed -i 's/security.ubuntu.com/mirrors.aliyun.com/' /etc/apt/sources.list && \
    apt update  && \
    apt install -y net-tools wget && \
    \
    #time zone
    apt install -y tzdata && \
    rm -f /etc/localtime && \
    cp -ap /usr/share/zoneinfo/PRC /etc/localtime && \
    apt remove -y tzdata && \
    mkdir -p /usr/share/zoneinfo/Asia && \
    cp /etc/localtime /usr/share/zoneinfo/Asia/Shanghai && \
    echo Asia/Shanghai > /etc/timezone && \
    \
    #jdk
    cd /tmp && \
    wget http://192.168.6.217/binaries/java/jdk-8u112-linux-x64.tar.gz && \
    export JDir=/opt/local/java && \
    mkdir -p $JDir && \
    tar -zxf jdk-8u112-linux-x64.tar.gz -C $JDir/ && \
    ln -fs $JDir/jdk1.8.0_112 $JDir/latest && \
    ln -s $JAVA_HOME/jre/bin/* /usr/bin/ && \
    rm -rf "$JAVA_HOME/"*src.zip && \
    rm -rf "$JAVA_HOME/lib/missioncontrol" \
           "$JAVA_HOME/lib/visualvm" \
           "$JAVA_HOME/lib/"*javafx* \
           "$JAVA_HOME/jre/lib/plugin.jar" \
           "$JAVA_HOME/jre/lib/ext/jfxrt.jar" \
           "$JAVA_HOME/jre/bin/javaws" \
           "$JAVA_HOME/jre/lib/javaws.jar" \
           "$JAVA_HOME/jre/lib/desktop" \
           "$JAVA_HOME/jre/plugin" \
           "$JAVA_HOME/jre/lib/"deploy* \
           "$JAVA_HOME/jre/lib/"*javafx* \
           "$JAVA_HOME/jre/lib/"*jfx* \
           "$JAVA_HOME/jre/lib/amd64/libdecora_sse.so" \
           "$JAVA_HOME/jre/lib/amd64/"libprism_*.so \
           "$JAVA_HOME/jre/lib/amd64/libfxplugins.so" \
           "$JAVA_HOME/jre/lib/amd64/libglass.so" \
           "$JAVA_HOME/jre/lib/amd64/libgstreamer-lite.so" \
           "$JAVA_HOME/jre/lib/amd64/"libjavafx*.so \
           "$JAVA_HOME/jre/lib/amd64/"libjfx*.so && \
    rm -rf "$JAVA_HOME/jre/bin/jjs" \
           "$JAVA_HOME/jre/bin/keytool" \
           "$JAVA_HOME/jre/bin/orbd" \
           "$JAVA_HOME/jre/bin/pack200" \
           "$JAVA_HOME/jre/bin/policytool" \
           "$JAVA_HOME/jre/bin/rmid" \
           "$JAVA_HOME/jre/bin/rmiregistry" \
           "$JAVA_HOME/jre/bin/servertool" \
           "$JAVA_HOME/jre/bin/tnameserv" \
           "$JAVA_HOME/jre/bin/unpack200" \
           "$JAVA_HOME/jre/lib/ext/nashorn.jar" \
           "$JAVA_HOME/jre/lib/jfr.jar" \
           "$JAVA_HOME/jre/lib/jfr" \
           "$JAVA_HOME/jre/lib/oblique-fonts" && \
    \
    #clean
    apt remove -y wget && \
    apt-get clean  && \
    find /var/log/ -type f |xargs rm -f && \
    rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* 

# docker build --no-cache -t ubuntu:jdk-8u112 -f dockerfile.ubuntu.jdk.txt.sh .
